<template>
    <div>
        <Header :title="header_title" :right_text="right_text"></Header>
        <div class="topheader page">
            <div class="fontBlack2 font40 title textL">自我评价</div>
            <div class="font28 fontBlack73 textL tip_i">一句话介绍自己，突出核心优势</div>
            <van-cell-group inset class="textarea">
                <van-field v-model="message" rows="16" autosize type="textarea" maxlength="200" placeholder="等待输入内容"
                    show-word-limit />
            </van-cell-group>
            <div class="bottom">
                <div @click="submit" class="font36 bgBlueFC fontWhite">保存</div>
            </div>
        </div>
        <dialog-btn :title="'是否保存当前页面'" :show="exitshow"></dialog-btn>
    </div>
</template>

<script>
import Header from '@/components/header.vue'
import DialogBtn from '@/components/dialogbtn.vue';
import { getCurrentInstance, reactive } from 'vue'
export default {
    components: {
        Header,
        DialogBtn
    },
    data() {
        return {
            header_title: '自我评价',
            message: '',
            data: {},
            exitshow: false,
            idcard: this.$store.state.idCard
        }
    },
    mounted() {
        this.token = this.$store.state.token;
        this.api = getCurrentInstance().appContext.config.globalProperties.$http;
        var that = this;
        var data = {
            identityNumber: that.idcard
        }
        this.api.get('/personnel/h5/resumeInfo/queryOne', data).then(res => {
            var data = res.data;
            if (data.resumeInfo) {
                that.data.version = data.resumeInfo.version;
                that.data.id = data.resumeInfo.id;
                that.message = data.resumeInfo.selfEvaluation
            } else {

            }
        })
    },
    methods: {
        submit() {
            if (!this.message) {
                this.$toast({
                    message: '请输入自我评价',
                    // duration: 0,
                });
                return;
            }
            let data = {
                selfEvaluation: this.message,
                identityNumber: this.token
            }
            if (this.data.id) {
                data.id = this.data.id;
            }
            if (this.data.version + '') {
                data.version = this.data.version;
            }
            let that = this;
            this.api.post('/personnel/h5/resumeInfo/addOrEditSelfEvaluation', data).then(res => {
                that.$router.replace('/resume');
            })
        },
        goback() {
            if (this.message) {
                this.exitshow = true;
            } else {
                this.$router.replace('/resume')
            }
        },
        ispopSub() {
            if (this.exitshow) {
                this.exitshow = false;
                this.submit();
                return;
            }
        },
        ispopClose() {
            if (this.exitshow) {
                this.exitshow = false;
                this.$router.replace('/resume')
            }
        },
    }
}
</script>

<style scoped>
.title {
    padding-top: 0.48rem;
    margin-bottom: 0.08rem;
    line-height: 0.56rem;
}

.tip_i {
    margin-bottom: 0.32rem;
}

.textarea .van-cell {
    padding: unset;
}

.van-cell-group--inset.textarea {
    margin: unset;
}

.bottom {
    position: fixed;
    width: 92%;
    padding: 0.32rem 0;
    background: white;
    bottom: 0;
}

.bottom div {
    padding: 0.24rem 2.71rem;
    border-radius: 0.48rem;
}
</style>